<template>
    <div class="menu-box">
        <div class="menu-box-item" v-for="item of list" :key="item.id">
            <div @click="innerPage(item.id)">
                <p class="mbi-img"><img :src="item.cover_img"></p>
                <p class="mbi-title">{{ item.title }}</p>
            </div>
        </div>
    </div>
</template>

<script>
  export default {
    name: 'Menu',
    data () {
      return {
        list:[]
      }
    },
    methods : {
      innerPage (id) {
        this.$router.push({name: 'innerPage', params: {id: id}})
      },
      getMenuInfo () {
        this.$axios.get("http://localhost:3000/getCate").then((response) => {
          if (response.data.data){
            this.list = response.data.data
          } else {
            console.log('Load Failed')
          }
        },(err) => {
          console.log('Load Pic Data Failed',err)
        })
      }
    },
    mounted () {
      this.getMenuInfo()
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.menu-box {
  position: absolute;
  width: 100%;
  top: 54px;
  overflow: hidden;
}
.menu-box-item {
  float: left;
  width: 48%;
  height: 150px;
  overflow: hidden;
  padding: 1%;
}
.mbi-img {
  width: 100%;
  height: 120px;
  overflow: hidden;
}
img {
  width: 100%;
}
.mbi-title {
  text-align: center;
  font-size: 12px;
  color: #fff;
  line-height: 30px;
}
</style>
